
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.io.nwchem &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script src="../../../_static/jquery.js"></script>
    <script src="../../../_static/underscore.js"></script>
    <script src="../../../_static/doctools.js"></script>
    <script src="../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.nwchem</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.io.nwchem</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">This module implements input and output processing from Nwchem.</span>

<span class="sd">2015/09/21 - Xin Chen (chenxin13@mails.tsinghua.edu.cn):</span>

<span class="sd">    NwOutput will read new kinds of data:</span>

<span class="sd">        1. normal hessian matrix.       [&quot;hessian&quot;]</span>
<span class="sd">        2. projected hessian matrix.    [&quot;projected_hessian&quot;]</span>
<span class="sd">        3. normal frequencies.          [&quot;normal_frequencies&quot;]</span>

<span class="sd">    For backward compatibility, the key for accessing the projected frequencies</span>
<span class="sd">    is still &#39;frequencies&#39;.</span>

<span class="sd">2015/10/12 - Xin Chen</span>
<span class="sd">    NwOutput will read new kinds of data:</span>

<span class="sd">        1. forces.                      [&quot;forces&quot;]</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">string</span> <span class="kn">import</span> <span class="n">Template</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<span class="kn">from</span> <span class="nn">monty.io</span> <span class="kn">import</span> <span class="n">zopen</span>

<span class="kn">from</span> <span class="nn">pymatgen.core.structure</span> <span class="kn">import</span> <span class="n">Molecule</span><span class="p">,</span> <span class="n">Structure</span>
<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">MSONable</span>
<span class="kn">from</span> <span class="nn">pymatgen.core.units</span> <span class="kn">import</span> <span class="n">Energy</span>
<span class="kn">from</span> <span class="nn">pymatgen.core.units</span> <span class="kn">import</span> <span class="n">FloatWithUnit</span>
<span class="kn">from</span> <span class="nn">pymatgen.analysis.excitation</span> <span class="kn">import</span> <span class="n">ExcitationSpectrum</span>


<span class="n">__author__</span> <span class="o">=</span> <span class="s2">&quot;Shyue Ping Ong&quot;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s2">&quot;Copyright 2012, The Materials Project&quot;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;0.1&quot;</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s2">&quot;Shyue Ping Ong&quot;</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">&quot;shyuep@gmail.com&quot;</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s2">&quot;6/5/13&quot;</span>

<span class="n">NWCHEM_BASIS_LIBRARY</span> <span class="o">=</span> <span class="kc">None</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;NWCHEM_BASIS_LIBRARY&quot;</span><span class="p">):</span>
    <span class="n">NWCHEM_BASIS_LIBRARY</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="p">[</span><span class="s2">&quot;NWCHEM_BASIS_LIBRARY&quot;</span><span class="p">]))</span>


<div class="viewcode-block" id="NwTask"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwTask">[docs]</a><span class="k">class</span> <span class="nc">NwTask</span><span class="p">(</span><span class="n">MSONable</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Base task for Nwchem.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">theories</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;g3gn&quot;</span><span class="p">:</span> <span class="s2">&quot;some description&quot;</span><span class="p">,</span>
                <span class="s2">&quot;scf&quot;</span><span class="p">:</span> <span class="s2">&quot;Hartree-Fock&quot;</span><span class="p">,</span>
                <span class="s2">&quot;dft&quot;</span><span class="p">:</span> <span class="s2">&quot;DFT&quot;</span><span class="p">,</span>
                <span class="s2">&quot;esp&quot;</span><span class="p">:</span> <span class="s2">&quot;ESP&quot;</span><span class="p">,</span>
                <span class="s2">&quot;sodft&quot;</span><span class="p">:</span> <span class="s2">&quot;Spin-Orbit DFT&quot;</span><span class="p">,</span>
                <span class="s2">&quot;mp2&quot;</span><span class="p">:</span> <span class="s2">&quot;MP2 using a semi-direct algorithm&quot;</span><span class="p">,</span>
                <span class="s2">&quot;direct_mp2&quot;</span><span class="p">:</span> <span class="s2">&quot;MP2 using a full-direct algorithm&quot;</span><span class="p">,</span>
                <span class="s2">&quot;rimp2&quot;</span><span class="p">:</span> <span class="s2">&quot;MP2 using the RI approximation&quot;</span><span class="p">,</span>
                <span class="s2">&quot;ccsd&quot;</span><span class="p">:</span> <span class="s2">&quot;Coupled-cluster single and double excitations&quot;</span><span class="p">,</span>
                <span class="s2">&quot;ccsd(t)&quot;</span><span class="p">:</span> <span class="s2">&quot;Coupled-cluster linearized triples approximation&quot;</span><span class="p">,</span>
                <span class="s2">&quot;ccsd+t(ccsd)&quot;</span><span class="p">:</span> <span class="s2">&quot;Fourth order triples contribution&quot;</span><span class="p">,</span>
                <span class="s2">&quot;mcscf&quot;</span><span class="p">:</span> <span class="s2">&quot;Multiconfiguration SCF&quot;</span><span class="p">,</span>
                <span class="s2">&quot;selci&quot;</span><span class="p">:</span> <span class="s2">&quot;Selected CI with perturbation correction&quot;</span><span class="p">,</span>
                <span class="s2">&quot;md&quot;</span><span class="p">:</span> <span class="s2">&quot;Classical molecular dynamics simulation&quot;</span><span class="p">,</span>
                <span class="s2">&quot;pspw&quot;</span><span class="p">:</span> <span class="s2">&quot;Pseudopotential plane-wave DFT for molecules and &quot;</span>
                        <span class="s2">&quot;insulating solids using NWPW&quot;</span><span class="p">,</span>
                <span class="s2">&quot;band&quot;</span><span class="p">:</span> <span class="s2">&quot;Pseudopotential plane-wave DFT for solids using NWPW&quot;</span><span class="p">,</span>
                <span class="s2">&quot;tce&quot;</span><span class="p">:</span> <span class="s2">&quot;Tensor Contraction Engine&quot;</span><span class="p">,</span>
                <span class="s2">&quot;tddft&quot;</span><span class="p">:</span> <span class="s2">&quot;Time Dependent DFT&quot;</span><span class="p">}</span>

    <span class="n">operations</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;energy&quot;</span><span class="p">:</span> <span class="s2">&quot;Evaluate the single point energy.&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;gradient&quot;</span><span class="p">:</span> <span class="s2">&quot;Evaluate the derivative of the energy with &quot;</span>
                              <span class="s2">&quot;respect to nuclear coordinates.&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;optimize&quot;</span><span class="p">:</span> <span class="s2">&quot;Minimize the energy by varying the molecular &quot;</span>
                              <span class="s2">&quot;structure.&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;saddle&quot;</span><span class="p">:</span> <span class="s2">&quot;Conduct a search for a transition state (or &quot;</span>
                            <span class="s2">&quot;saddle point).&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;hessian&quot;</span><span class="p">:</span> <span class="s2">&quot;Compute second derivatives.&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;frequencies&quot;</span><span class="p">:</span> <span class="s2">&quot;Compute second derivatives and print out an &quot;</span>
                                 <span class="s2">&quot;analysis of molecular vibrations.&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;freq&quot;</span><span class="p">:</span> <span class="s2">&quot;Same as frequencies.&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;vscf&quot;</span><span class="p">:</span> <span class="s2">&quot;Compute anharmonic contributions to the &quot;</span>
                          <span class="s2">&quot;vibrational modes.&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;property&quot;</span><span class="p">:</span> <span class="s2">&quot;Calculate the properties for the wave &quot;</span>
                              <span class="s2">&quot;function.&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;dynamics&quot;</span><span class="p">:</span> <span class="s2">&quot;Perform classical molecular dynamics.&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;thermodynamics&quot;</span><span class="p">:</span> <span class="s2">&quot;Perform multi-configuration &quot;</span>
                                    <span class="s2">&quot;thermodynamic integration using &quot;</span>
                                    <span class="s2">&quot;classical MD.&quot;</span><span class="p">,</span>
                  <span class="s2">&quot;&quot;</span><span class="p">:</span> <span class="s2">&quot;dummy&quot;</span><span class="p">}</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">charge</span><span class="p">,</span> <span class="n">spin_multiplicity</span><span class="p">,</span> <span class="n">basis_set</span><span class="p">,</span>
                 <span class="n">basis_set_option</span><span class="o">=</span><span class="s2">&quot;cartesian&quot;</span><span class="p">,</span>
                 <span class="n">title</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">theory</span><span class="o">=</span><span class="s2">&quot;dft&quot;</span><span class="p">,</span> <span class="n">operation</span><span class="o">=</span><span class="s2">&quot;optimize&quot;</span><span class="p">,</span>
                 <span class="n">theory_directives</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">alternate_directives</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Very flexible arguments to support many types of potential setups.</span>
<span class="sd">        Users should use more friendly static methods unless they need the</span>
<span class="sd">        flexibility.</span>

<span class="sd">        Args:</span>
<span class="sd">            charge: Charge of the molecule. If None, charge on molecule is</span>
<span class="sd">                used. Defaults to None. This allows the input file to be set a</span>
<span class="sd">                charge independently from the molecule itself.</span>
<span class="sd">            spin_multiplicity: Spin multiplicity of molecule. Defaults to None,</span>
<span class="sd">                which means that the spin multiplicity is set to 1 if the</span>
<span class="sd">                molecule has no unpaired electrons and to 2 if there are</span>
<span class="sd">                unpaired electrons.</span>
<span class="sd">            basis_set: The basis set used for the task as a dict. E.g.,</span>
<span class="sd">                {&quot;C&quot;: &quot;6-311++G**&quot;, &quot;H&quot;: &quot;6-31++G**&quot;}.</span>
<span class="sd">            basis_set_option: cartesian (default) | spherical,</span>
<span class="sd">            title: Title for the task. Defaults to None, which means a title</span>
<span class="sd">                based on the theory and operation of the task is</span>
<span class="sd">                autogenerated.</span>
<span class="sd">            theory: The theory used for the task. Defaults to &quot;dft&quot;.</span>
<span class="sd">            operation: The operation for the task. Defaults to &quot;optimize&quot;.</span>
<span class="sd">            theory_directives: A dict of theory directives. For example,</span>
<span class="sd">                if you are running dft calculations, you may specify the</span>
<span class="sd">                exchange correlation functional using {&quot;xc&quot;: &quot;b3lyp&quot;}.</span>
<span class="sd">            alternate_directives: A dict of alternate directives. For</span>
<span class="sd">                example, to perform cosmo calculations and dielectric</span>
<span class="sd">                constant of 78, you&#39;d supply {&#39;cosmo&#39;: {&quot;dielectric&quot;: 78}}.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># Basic checks.</span>
        <span class="k">if</span> <span class="n">theory</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">NwTask</span><span class="o">.</span><span class="n">theories</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="k">raise</span> <span class="n">NwInputError</span><span class="p">(</span><span class="s2">&quot;Invalid theory </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">theory</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">operation</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">NwTask</span><span class="o">.</span><span class="n">operations</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="k">raise</span> <span class="n">NwInputError</span><span class="p">(</span><span class="s2">&quot;Invalid operation </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">operation</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">charge</span> <span class="o">=</span> <span class="n">charge</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="n">spin_multiplicity</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">title</span> <span class="o">=</span> <span class="n">title</span> <span class="k">if</span> <span class="n">title</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">theory</span><span class="p">,</span>
                                                                    <span class="n">operation</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">theory</span> <span class="o">=</span> <span class="n">theory</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span> <span class="o">=</span> <span class="n">basis_set</span> <span class="ow">or</span> <span class="p">{}</span>
        <span class="k">if</span> <span class="n">NWCHEM_BASIS_LIBRARY</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">b</span> <span class="ow">in</span> <span class="nb">set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span><span class="o">.</span><span class="n">values</span><span class="p">()):</span>
                <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;\*&#39;</span><span class="p">,</span> <span class="s2">&quot;s&quot;</span><span class="p">,</span> <span class="n">b</span><span class="o">.</span><span class="n">lower</span><span class="p">())</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">NWCHEM_BASIS_LIBRARY</span><span class="p">:</span>
                    <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                        <span class="s2">&quot;Basis set </span><span class="si">%s</span><span class="s2"> not in in NWCHEM_BASIS_LIBRARY&quot;</span> <span class="o">%</span> <span class="n">b</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">basis_set_option</span> <span class="o">=</span> <span class="n">basis_set_option</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">operation</span> <span class="o">=</span> <span class="n">operation</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">theory_directives</span> <span class="o">=</span> <span class="n">theory_directives</span> <span class="ow">or</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">alternate_directives</span> <span class="o">=</span> <span class="n">alternate_directives</span> <span class="ow">or</span> <span class="p">{}</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">bset_spec</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">el</span><span class="p">,</span> <span class="n">bset</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
            <span class="n">bset_spec</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> library </span><span class="se">\&quot;</span><span class="si">{}</span><span class="se">\&quot;</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">el</span><span class="p">,</span> <span class="n">bset</span><span class="p">))</span>
        <span class="n">theory_spec</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">theory_directives</span><span class="p">:</span>
            <span class="n">theory_spec</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">theory</span><span class="p">))</span>
            <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">theory_directives</span><span class="o">.</span><span class="n">keys</span><span class="p">()):</span>
                <span class="n">theory_spec</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">theory_directives</span><span class="p">[</span>
                    <span class="n">k</span><span class="p">]))</span>
            <span class="n">theory_spec</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;end&quot;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">alternate_directives</span><span class="o">.</span><span class="n">keys</span><span class="p">()):</span>
            <span class="n">theory_spec</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">k2</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">alternate_directives</span><span class="p">[</span><span class="n">k</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()):</span>
                <span class="n">theory_spec</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">k2</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">alternate_directives</span><span class="p">[</span><span class="n">k</span><span class="p">][</span><span class="n">k2</span><span class="p">]))</span>
            <span class="n">theory_spec</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;end&quot;</span><span class="p">)</span>

        <span class="n">t</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span><span class="s2">&quot;&quot;&quot;title &quot;$title&quot;</span>
<span class="s2">charge $charge</span>
<span class="s2">basis $basis_set_option</span>
<span class="s2">$bset_spec</span>
<span class="s2">end</span>
<span class="s2">$theory_spec</span>
<span class="s2">&quot;&quot;&quot;</span><span class="p">)</span>

        <span class="n">output</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">substitute</span><span class="p">(</span>
            <span class="n">title</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">,</span> <span class="n">charge</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">charge</span><span class="p">),</span>
            <span class="n">spinmult</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span><span class="p">,</span>
            <span class="n">basis_set_option</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">basis_set_option</span><span class="p">,</span>
            <span class="n">bset_spec</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">bset_spec</span><span class="p">),</span>
            <span class="n">theory_spec</span><span class="o">=</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">theory_spec</span><span class="p">),</span>
            <span class="n">theory</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">theory</span><span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">operation</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">output</span> <span class="o">+=</span> <span class="s2">&quot;task </span><span class="si">%s</span><span class="s2"> </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">theory</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">operation</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">output</span>

<div class="viewcode-block" id="NwTask.as_dict"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwTask.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns: MSONable dict.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">{</span><span class="s2">&quot;@module&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span><span class="p">,</span>
                <span class="s2">&quot;@class&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                <span class="s2">&quot;charge&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">charge</span><span class="p">,</span>
                <span class="s2">&quot;spin_multiplicity&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">spin_multiplicity</span><span class="p">,</span>
                <span class="s2">&quot;title&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">title</span><span class="p">,</span> <span class="s2">&quot;theory&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">theory</span><span class="p">,</span>
                <span class="s2">&quot;operation&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">operation</span><span class="p">,</span> <span class="s2">&quot;basis_set&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">basis_set</span><span class="p">,</span>
                <span class="s2">&quot;basis_set_option&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">basis_set_option</span><span class="p">,</span>
                <span class="s2">&quot;theory_directives&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">theory_directives</span><span class="p">,</span>
                <span class="s2">&quot;alternate_directives&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">alternate_directives</span><span class="p">}</span></div>

<div class="viewcode-block" id="NwTask.from_dict"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwTask.from_dict">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            d (dict): Dict representation</span>

<span class="sd">        Returns:</span>
<span class="sd">            NwTask</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">NwTask</span><span class="p">(</span><span class="n">charge</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;charge&quot;</span><span class="p">],</span>
                      <span class="n">spin_multiplicity</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;spin_multiplicity&quot;</span><span class="p">],</span>
                      <span class="n">title</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;title&quot;</span><span class="p">],</span> <span class="n">theory</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;theory&quot;</span><span class="p">],</span>
                      <span class="n">operation</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;operation&quot;</span><span class="p">],</span> <span class="n">basis_set</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;basis_set&quot;</span><span class="p">],</span>
                      <span class="n">basis_set_option</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s1">&#39;basis_set_option&#39;</span><span class="p">],</span>
                      <span class="n">theory_directives</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;theory_directives&quot;</span><span class="p">],</span>
                      <span class="n">alternate_directives</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;alternate_directives&quot;</span><span class="p">])</span></div>

<div class="viewcode-block" id="NwTask.from_molecule"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwTask.from_molecule">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_molecule</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">mol</span><span class="p">,</span> <span class="n">theory</span><span class="p">,</span> <span class="n">charge</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">spin_multiplicity</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                      <span class="n">basis_set</span><span class="o">=</span><span class="s2">&quot;6-31g&quot;</span><span class="p">,</span> <span class="n">basis_set_option</span><span class="o">=</span><span class="s2">&quot;cartesian&quot;</span><span class="p">,</span>
                      <span class="n">title</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">operation</span><span class="o">=</span><span class="s2">&quot;optimize&quot;</span><span class="p">,</span> <span class="n">theory_directives</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                      <span class="n">alternate_directives</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Very flexible arguments to support many types of potential setups.</span>
<span class="sd">        Users should use more friendly static methods unless they need the</span>
<span class="sd">        flexibility.</span>

<span class="sd">        Args:</span>
<span class="sd">            mol: Input molecule</span>
<span class="sd">            charge: Charge of the molecule. If None, charge on molecule is</span>
<span class="sd">                used. Defaults to None. This allows the input file to be set a</span>
<span class="sd">                charge independently from the molecule itself.</span>
<span class="sd">            spin_multiplicity: Spin multiplicity of molecule. Defaults to None,</span>
<span class="sd">                which means that the spin multiplicity is set to 1 if the</span>
<span class="sd">                molecule has no unpaired electrons and to 2 if there are</span>
<span class="sd">                unpaired electrons.</span>
<span class="sd">            basis_set: The basis set to be used as string or a dict. E.g.,</span>
<span class="sd">                {&quot;C&quot;: &quot;6-311++G**&quot;, &quot;H&quot;: &quot;6-31++G**&quot;} or &quot;6-31G&quot;. If string,</span>
<span class="sd">                same basis set is used for all elements.</span>
<span class="sd">            basis_set_option: cartesian (default) | spherical,</span>
<span class="sd">            title: Title for the task. Defaults to None, which means a title</span>
<span class="sd">                based on the theory and operation of the task is</span>
<span class="sd">                autogenerated.</span>
<span class="sd">            theory: The theory used for the task. Defaults to &quot;dft&quot;.</span>
<span class="sd">            operation: The operation for the task. Defaults to &quot;optimize&quot;.</span>
<span class="sd">            theory_directives: A dict of theory directives. For example,</span>
<span class="sd">                if you are running dft calculations, you may specify the</span>
<span class="sd">                exchange correlation functional using {&quot;xc&quot;: &quot;b3lyp&quot;}.</span>
<span class="sd">            alternate_directives: A dict of alternate directives. For</span>
<span class="sd">                example, to perform cosmo calculations with DFT, you&#39;d supply</span>
<span class="sd">                {&#39;cosmo&#39;: &quot;cosmo&quot;}.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">title</span> <span class="o">=</span> <span class="n">title</span> <span class="k">if</span> <span class="n">title</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
            <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;\s&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">mol</span><span class="o">.</span><span class="n">formula</span><span class="p">),</span> <span class="n">theory</span><span class="p">,</span> <span class="n">operation</span><span class="p">)</span>

        <span class="n">charge</span> <span class="o">=</span> <span class="n">charge</span> <span class="k">if</span> <span class="n">charge</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">mol</span><span class="o">.</span><span class="n">charge</span>
        <span class="n">nelectrons</span> <span class="o">=</span> <span class="o">-</span> <span class="n">charge</span> <span class="o">+</span> <span class="n">mol</span><span class="o">.</span><span class="n">charge</span> <span class="o">+</span> <span class="n">mol</span><span class="o">.</span><span class="n">nelectrons</span>
        <span class="k">if</span> <span class="n">spin_multiplicity</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="n">spin_multiplicity</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">nelectrons</span> <span class="o">+</span> <span class="n">spin_multiplicity</span><span class="p">)</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;Charge of </span><span class="si">{}</span><span class="s2"> and spin multiplicity of </span><span class="si">{}</span><span class="s2"> is&quot;</span>
                    <span class="s2">&quot; not possible for this molecule&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">charge</span><span class="p">,</span> <span class="n">spin_multiplicity</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">charge</span> <span class="o">==</span> <span class="n">mol</span><span class="o">.</span><span class="n">charge</span><span class="p">:</span>
            <span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="n">mol</span><span class="o">.</span><span class="n">spin_multiplicity</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="mi">1</span> <span class="k">if</span> <span class="n">nelectrons</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">0</span> <span class="k">else</span> <span class="mi">2</span>

        <span class="n">elements</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">mol</span><span class="o">.</span><span class="n">composition</span><span class="o">.</span><span class="n">get_el_amt_dict</span><span class="p">()</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">basis_set</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="n">basis_set</span> <span class="o">=</span> <span class="p">{</span><span class="n">el</span><span class="p">:</span> <span class="n">basis_set</span> <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="n">elements</span><span class="p">}</span>

        <span class="n">basis_set_option</span> <span class="o">=</span> <span class="n">basis_set_option</span>

        <span class="k">return</span> <span class="n">NwTask</span><span class="p">(</span><span class="n">charge</span><span class="p">,</span> <span class="n">spin_multiplicity</span><span class="p">,</span> <span class="n">basis_set</span><span class="p">,</span>
                      <span class="n">basis_set_option</span><span class="o">=</span><span class="n">basis_set_option</span><span class="p">,</span>
                      <span class="n">title</span><span class="o">=</span><span class="n">title</span><span class="p">,</span> <span class="n">theory</span><span class="o">=</span><span class="n">theory</span><span class="p">,</span> <span class="n">operation</span><span class="o">=</span><span class="n">operation</span><span class="p">,</span>
                      <span class="n">theory_directives</span><span class="o">=</span><span class="n">theory_directives</span><span class="p">,</span>
                      <span class="n">alternate_directives</span><span class="o">=</span><span class="n">alternate_directives</span><span class="p">)</span></div>

<div class="viewcode-block" id="NwTask.dft_task"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwTask.dft_task">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">dft_task</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">mol</span><span class="p">,</span> <span class="n">xc</span><span class="o">=</span><span class="s2">&quot;b3lyp&quot;</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        A class method for quickly creating DFT tasks with optional</span>
<span class="sd">        cosmo parameter .</span>

<span class="sd">        Args:</span>
<span class="sd">            mol: Input molecule</span>
<span class="sd">            xc: Exchange correlation to use.</span>
<span class="sd">            \\*\\*kwargs: Any of the other kwargs supported by NwTask. Note the</span>
<span class="sd">                theory is always &quot;dft&quot; for a dft task.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">t</span> <span class="o">=</span> <span class="n">NwTask</span><span class="o">.</span><span class="n">from_molecule</span><span class="p">(</span><span class="n">mol</span><span class="p">,</span> <span class="n">theory</span><span class="o">=</span><span class="s2">&quot;dft&quot;</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="n">t</span><span class="o">.</span><span class="n">theory_directives</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;xc&quot;</span><span class="p">:</span> <span class="n">xc</span><span class="p">,</span>
                                    <span class="s2">&quot;mult&quot;</span><span class="p">:</span> <span class="n">t</span><span class="o">.</span><span class="n">spin_multiplicity</span><span class="p">})</span>
        <span class="k">return</span> <span class="n">t</span></div>

<div class="viewcode-block" id="NwTask.esp_task"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwTask.esp_task">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">esp_task</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">mol</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sa">r</span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        A class method for quickly creating ESP tasks with RESP</span>
<span class="sd">        charge fitting.</span>

<span class="sd">        Args:</span>
<span class="sd">            mol: Input molecule</span>
<span class="sd">            \\*\\*kwargs: Any of the other kwargs supported by NwTask. Note the</span>
<span class="sd">                theory is always &quot;dft&quot; for a dft task.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">NwTask</span><span class="o">.</span><span class="n">from_molecule</span><span class="p">(</span><span class="n">mol</span><span class="p">,</span> <span class="n">theory</span><span class="o">=</span><span class="s2">&quot;esp&quot;</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="NwInput"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwInput">[docs]</a><span class="k">class</span> <span class="nc">NwInput</span><span class="p">(</span><span class="n">MSONable</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    An object representing a Nwchem input file, which is essentially a list</span>
<span class="sd">    of tasks on a particular molecule.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mol</span><span class="p">,</span> <span class="n">tasks</span><span class="p">,</span> <span class="n">directives</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">geometry_options</span><span class="o">=</span><span class="p">(</span><span class="s2">&quot;units&quot;</span><span class="p">,</span> <span class="s2">&quot;angstroms&quot;</span><span class="p">),</span>
                 <span class="n">symmetry_options</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                 <span class="n">memory_options</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            mol: Input molecule. If molecule is a single string, it is used as a</span>
<span class="sd">                direct input to the geometry section of the Gaussian input</span>
<span class="sd">                file.</span>
<span class="sd">            tasks: List of NwTasks.</span>
<span class="sd">            directives: List of root level directives as tuple. E.g.,</span>
<span class="sd">                [(&quot;start&quot;, &quot;water&quot;), (&quot;print&quot;, &quot;high&quot;)]</span>
<span class="sd">            geometry_options: Additional list of options to be supplied to the</span>
<span class="sd">                geometry. E.g., [&quot;units&quot;, &quot;angstroms&quot;, &quot;noautoz&quot;]. Defaults to</span>
<span class="sd">                (&quot;units&quot;, &quot;angstroms&quot;).</span>
<span class="sd">            symmetry_options: Addition list of option to be supplied to the</span>
<span class="sd">                symmetry. E.g. [&quot;c1&quot;] to turn off the symmetry</span>
<span class="sd">            memory_options: Memory controlling options. str.</span>
<span class="sd">                E.g &quot;total 1000 mb stack 400 mb&quot;</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span> <span class="o">=</span> <span class="n">mol</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">directives</span> <span class="o">=</span> <span class="n">directives</span> <span class="k">if</span> <span class="n">directives</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">tasks</span> <span class="o">=</span> <span class="n">tasks</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">geometry_options</span> <span class="o">=</span> <span class="n">geometry_options</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">symmetry_options</span> <span class="o">=</span> <span class="n">symmetry_options</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">memory_options</span> <span class="o">=</span> <span class="n">memory_options</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">molecule</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns molecule associated with this GaussianInput.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">o</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">memory_options</span><span class="p">:</span>
            <span class="n">o</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;memory &#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">memory_options</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">directives</span><span class="p">:</span>
            <span class="n">o</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">d</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span>
        <span class="n">o</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;geometry &quot;</span>
                 <span class="o">+</span> <span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">geometry_options</span><span class="p">))</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">symmetry_options</span><span class="p">:</span>
            <span class="n">o</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot; symmetry &quot;</span> <span class="o">+</span> <span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">symmetry_options</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">site</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="p">:</span>
            <span class="n">o</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2"> </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">site</span><span class="o">.</span><span class="n">specie</span><span class="o">.</span><span class="n">symbol</span><span class="p">,</span> <span class="n">site</span><span class="o">.</span><span class="n">x</span><span class="p">,</span> <span class="n">site</span><span class="o">.</span><span class="n">y</span><span class="p">,</span>
                                           <span class="n">site</span><span class="o">.</span><span class="n">z</span><span class="p">))</span>
        <span class="n">o</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;end</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">tasks</span><span class="p">:</span>
            <span class="n">o</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">))</span>
            <span class="n">o</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">o</span><span class="p">)</span>

<div class="viewcode-block" id="NwInput.write_file"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwInput.write_file">[docs]</a>    <span class="k">def</span> <span class="nf">write_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            filename (str): Filename</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;w&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="fm">__str__</span><span class="p">())</span></div>

<div class="viewcode-block" id="NwInput.as_dict"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwInput.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns: MSONable dict</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">{</span>
            <span class="s2">&quot;mol&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_mol</span><span class="o">.</span><span class="n">as_dict</span><span class="p">(),</span>
            <span class="s2">&quot;tasks&quot;</span><span class="p">:</span> <span class="p">[</span><span class="n">t</span><span class="o">.</span><span class="n">as_dict</span><span class="p">()</span> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">tasks</span><span class="p">],</span>
            <span class="s2">&quot;directives&quot;</span><span class="p">:</span> <span class="p">[</span><span class="nb">list</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">directives</span><span class="p">],</span>
            <span class="s2">&quot;geometry_options&quot;</span><span class="p">:</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">geometry_options</span><span class="p">),</span>
            <span class="s2">&quot;symmetry_options&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">symmetry_options</span><span class="p">,</span>
            <span class="s2">&quot;memory_options&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">memory_options</span>
        <span class="p">}</span></div>

<div class="viewcode-block" id="NwInput.from_dict"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwInput.from_dict">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            d (dict): Dict representation</span>

<span class="sd">        Returns:</span>
<span class="sd">            NwInput</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">NwInput</span><span class="p">(</span><span class="n">Molecule</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;mol&quot;</span><span class="p">]),</span>
                       <span class="n">tasks</span><span class="o">=</span><span class="p">[</span><span class="n">NwTask</span><span class="o">.</span><span class="n">from_dict</span><span class="p">(</span><span class="n">dt</span><span class="p">)</span> <span class="k">for</span> <span class="n">dt</span> <span class="ow">in</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;tasks&quot;</span><span class="p">]],</span>
                       <span class="n">directives</span><span class="o">=</span><span class="p">[</span><span class="nb">tuple</span><span class="p">(</span><span class="n">li</span><span class="p">)</span> <span class="k">for</span> <span class="n">li</span> <span class="ow">in</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;directives&quot;</span><span class="p">]],</span>
                       <span class="n">geometry_options</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;geometry_options&quot;</span><span class="p">],</span>
                       <span class="n">symmetry_options</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;symmetry_options&quot;</span><span class="p">],</span>
                       <span class="n">memory_options</span><span class="o">=</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;memory_options&quot;</span><span class="p">])</span></div>

<div class="viewcode-block" id="NwInput.from_string"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwInput.from_string">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_string</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">string_input</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Read an NwInput from a string. Currently tested to work with</span>
<span class="sd">        files generated from this class itself.</span>

<span class="sd">        Args:</span>
<span class="sd">            string_input: string_input to parse.</span>

<span class="sd">        Returns:</span>
<span class="sd">            NwInput object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">directives</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">tasks</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">charge</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">title</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">basis_set</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">basis_set_option</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">theory_directives</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">geom_options</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">symmetry_options</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">memory_options</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">lines</span> <span class="o">=</span> <span class="n">string_input</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>
        <span class="k">while</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="n">l</span> <span class="o">=</span> <span class="n">lines</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">l</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                <span class="k">continue</span>

            <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;geometry&quot;</span><span class="p">:</span>
                <span class="n">geom_options</span> <span class="o">=</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
                <span class="n">l</span> <span class="o">=</span> <span class="n">lines</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
                <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                <span class="k">if</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;symmetry&quot;</span><span class="p">:</span>
                    <span class="n">symmetry_options</span> <span class="o">=</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
                    <span class="n">l</span> <span class="o">=</span> <span class="n">lines</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
                <span class="c1"># Parse geometry</span>
                <span class="n">species</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="n">coords</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">while</span> <span class="n">l</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">&quot;end&quot;</span><span class="p">:</span>
                    <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                    <span class="n">species</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                    <span class="n">coords</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">:]])</span>
                    <span class="n">l</span> <span class="o">=</span> <span class="n">lines</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
                <span class="n">mol</span> <span class="o">=</span> <span class="n">Molecule</span><span class="p">(</span><span class="n">species</span><span class="p">,</span> <span class="n">coords</span><span class="p">)</span>
            <span class="k">elif</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;charge&quot;</span><span class="p">:</span>
                <span class="n">charge</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
            <span class="k">elif</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;title&quot;</span><span class="p">:</span>
                <span class="n">title</span> <span class="o">=</span> <span class="n">l</span><span class="p">[</span><span class="mi">5</span><span class="p">:]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\&quot;</span><span class="s2">&quot;</span><span class="p">)</span>
            <span class="k">elif</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;basis&quot;</span><span class="p">:</span>
                <span class="c1"># Parse basis sets</span>
                <span class="n">l</span> <span class="o">=</span> <span class="n">lines</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
                <span class="n">basis_set</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="k">while</span> <span class="n">l</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">&quot;end&quot;</span><span class="p">:</span>
                    <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                    <span class="n">basis_set</span><span class="p">[</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">toks</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\&quot;</span><span class="s2">&quot;</span><span class="p">)</span>
                    <span class="n">l</span> <span class="o">=</span> <span class="n">lines</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
            <span class="k">elif</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="n">NwTask</span><span class="o">.</span><span class="n">theories</span><span class="p">:</span>
                <span class="c1"># read the basis_set_option</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">toks</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="n">basis_set_option</span> <span class="o">=</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="c1"># Parse theory directives.</span>
                <span class="n">theory</span> <span class="o">=</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
                <span class="n">l</span> <span class="o">=</span> <span class="n">lines</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
                <span class="n">theory_directives</span><span class="p">[</span><span class="n">theory</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="k">while</span> <span class="n">l</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">!=</span> <span class="s2">&quot;end&quot;</span><span class="p">:</span>
                    <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                    <span class="n">theory_directives</span><span class="p">[</span><span class="n">theory</span><span class="p">][</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="n">toks</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
                    <span class="k">if</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;mult&quot;</span><span class="p">:</span>
                        <span class="n">spin_multiplicity</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
                    <span class="n">l</span> <span class="o">=</span> <span class="n">lines</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
            <span class="k">elif</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;task&quot;</span><span class="p">:</span>
                <span class="n">tasks</span><span class="o">.</span><span class="n">append</span><span class="p">(</span>
                    <span class="n">NwTask</span><span class="p">(</span><span class="n">charge</span><span class="o">=</span><span class="n">charge</span><span class="p">,</span>
                           <span class="n">spin_multiplicity</span><span class="o">=</span><span class="n">spin_multiplicity</span><span class="p">,</span>
                           <span class="n">title</span><span class="o">=</span><span class="n">title</span><span class="p">,</span> <span class="n">theory</span><span class="o">=</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span>
                           <span class="n">operation</span><span class="o">=</span><span class="n">toks</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="n">basis_set</span><span class="o">=</span><span class="n">basis_set</span><span class="p">,</span>
                           <span class="n">basis_set_option</span><span class="o">=</span><span class="n">basis_set_option</span><span class="p">,</span>
                           <span class="n">theory_directives</span><span class="o">=</span><span class="n">theory_directives</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">])))</span>
            <span class="k">elif</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;memory&quot;</span><span class="p">:</span>
                <span class="n">memory_options</span> <span class="o">=</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">directives</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">())</span>

        <span class="k">return</span> <span class="n">NwInput</span><span class="p">(</span><span class="n">mol</span><span class="p">,</span> <span class="n">tasks</span><span class="o">=</span><span class="n">tasks</span><span class="p">,</span> <span class="n">directives</span><span class="o">=</span><span class="n">directives</span><span class="p">,</span>
                       <span class="n">geometry_options</span><span class="o">=</span><span class="n">geom_options</span><span class="p">,</span>
                       <span class="n">symmetry_options</span><span class="o">=</span><span class="n">symmetry_options</span><span class="p">,</span>
                       <span class="n">memory_options</span><span class="o">=</span><span class="n">memory_options</span><span class="p">)</span></div>

<div class="viewcode-block" id="NwInput.from_file"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwInput.from_file">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_file</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Read an NwInput from a file. Currently tested to work with</span>
<span class="sd">        files generated from this class itself.</span>

<span class="sd">        Args:</span>
<span class="sd">            filename: Filename to parse.</span>

<span class="sd">        Returns:</span>
<span class="sd">            NwInput object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">())</span></div></div>


<div class="viewcode-block" id="NwInputError"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwInputError">[docs]</a><span class="k">class</span> <span class="nc">NwInputError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Error class for NwInput.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">pass</span></div>


<div class="viewcode-block" id="NwOutput"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwOutput">[docs]</a><span class="k">class</span> <span class="nc">NwOutput</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    A Nwchem output file parser. Very basic for now - supports only dft and</span>
<span class="sd">    only parses energies and geometries. Please note that Nwchem typically</span>
<span class="sd">    outputs energies in either au or kJ/mol. All energies are converted to</span>
<span class="sd">    eV in the parser.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            filename: Filename to read.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filename</span> <span class="o">=</span> <span class="n">filename</span>

        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>

        <span class="n">chunks</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;NWChem Input Module&quot;</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;CITATION&quot;</span><span class="p">,</span> <span class="n">chunks</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]):</span>
            <span class="n">chunks</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
        <span class="n">preamble</span> <span class="o">=</span> <span class="n">chunks</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">raw</span> <span class="o">=</span> <span class="n">data</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">job_info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parse_preamble</span><span class="p">(</span><span class="n">preamble</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_parse_job</span><span class="p">(</span><span class="n">c</span><span class="p">)</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">chunks</span><span class="p">]</span>

<div class="viewcode-block" id="NwOutput.parse_tddft"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwOutput.parse_tddft">[docs]</a>    <span class="k">def</span> <span class="nf">parse_tddft</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Parses TDDFT roots. Adapted from nw_spectrum.py script.</span>

<span class="sd">        Returns:</span>
<span class="sd">            {</span>
<span class="sd">                &quot;singlet&quot;: [</span>
<span class="sd">                    {</span>
<span class="sd">                        &quot;energy&quot;: float,</span>
<span class="sd">                        &quot;osc_strength: float</span>
<span class="sd">                    }</span>
<span class="sd">                ],</span>
<span class="sd">                &quot;triplet&quot;: [</span>
<span class="sd">                    {</span>
<span class="sd">                        &quot;energy&quot;: float</span>
<span class="sd">                    }</span>
<span class="sd">                ]</span>
<span class="sd">            }</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">start_tag</span> <span class="o">=</span> <span class="s2">&quot;Convergence criterion met&quot;</span>
        <span class="n">end_tag</span> <span class="o">=</span> <span class="s2">&quot;Excited state energy&quot;</span>
        <span class="n">singlet_tag</span> <span class="o">=</span> <span class="s2">&quot;singlet excited&quot;</span>
        <span class="n">triplet_tag</span> <span class="o">=</span> <span class="s2">&quot;triplet excited&quot;</span>
        <span class="n">state</span> <span class="o">=</span> <span class="s2">&quot;singlet&quot;</span>
        <span class="n">inside</span> <span class="o">=</span> <span class="kc">False</span>  <span class="c1"># true when we are inside output block</span>

        <span class="n">lines</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">raw</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

        <span class="n">roots</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;singlet&quot;</span><span class="p">:</span> <span class="p">[],</span> <span class="s2">&quot;triplet&quot;</span><span class="p">:</span> <span class="p">[]}</span>

        <span class="k">while</span> <span class="n">lines</span><span class="p">:</span>
            <span class="n">line</span> <span class="o">=</span> <span class="n">lines</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>

            <span class="k">if</span> <span class="n">start_tag</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                <span class="n">inside</span> <span class="o">=</span> <span class="kc">True</span>

            <span class="k">elif</span> <span class="n">end_tag</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                <span class="n">inside</span> <span class="o">=</span> <span class="kc">False</span>

            <span class="k">elif</span> <span class="n">singlet_tag</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                <span class="n">state</span> <span class="o">=</span> <span class="s2">&quot;singlet&quot;</span>

            <span class="k">elif</span> <span class="n">triplet_tag</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                <span class="n">state</span> <span class="o">=</span> <span class="s2">&quot;triplet&quot;</span>

            <span class="k">elif</span> <span class="n">inside</span> <span class="ow">and</span> <span class="s2">&quot;Root&quot;</span> <span class="ow">in</span> <span class="n">line</span> <span class="ow">and</span> <span class="s2">&quot;eV&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                <span class="n">toks</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                <span class="n">roots</span><span class="p">[</span><span class="n">state</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s2">&quot;energy&quot;</span><span class="p">:</span> <span class="nb">float</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">])})</span>

            <span class="k">elif</span> <span class="n">inside</span> <span class="ow">and</span> <span class="s2">&quot;Dipole Oscillator Strength&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                <span class="n">osc</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
                <span class="n">roots</span><span class="p">[</span><span class="n">state</span><span class="p">][</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="s2">&quot;osc_strength&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">osc</span>

        <span class="k">return</span> <span class="n">roots</span></div>

<div class="viewcode-block" id="NwOutput.get_excitation_spectrum"><a class="viewcode-back" href="../../../pymatgen.io.nwchem.html#pymatgen.io.nwchem.NwOutput.get_excitation_spectrum">[docs]</a>    <span class="k">def</span> <span class="nf">get_excitation_spectrum</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">width</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> <span class="n">npoints</span><span class="o">=</span><span class="mi">2000</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Generate an excitation spectra from the singlet roots of TDDFT</span>
<span class="sd">        calculations.</span>

<span class="sd">        Args:</span>
<span class="sd">            width (float): Width for Gaussian smearing.</span>
<span class="sd">            npoints (int): Number of energy points. More points =&gt; smoother</span>
<span class="sd">                curve.</span>

<span class="sd">        Returns:</span>
<span class="sd">            (ExcitationSpectrum) which can be plotted using</span>
<span class="sd">                pymatgen.vis.plotters.SpectrumPlotter.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">roots</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">parse_tddft</span><span class="p">()</span>
        <span class="n">data</span> <span class="o">=</span> <span class="n">roots</span><span class="p">[</span><span class="s2">&quot;singlet&quot;</span><span class="p">]</span>
        <span class="n">en</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;energy&quot;</span><span class="p">]</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">data</span><span class="p">])</span>
        <span class="n">osc</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;osc_strength&quot;</span><span class="p">]</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">data</span><span class="p">])</span>

        <span class="n">epad</span> <span class="o">=</span> <span class="mf">20.0</span> <span class="o">*</span> <span class="n">width</span>
        <span class="n">emin</span> <span class="o">=</span> <span class="n">en</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">epad</span>
        <span class="n">emax</span> <span class="o">=</span> <span class="n">en</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">epad</span>
        <span class="n">de</span> <span class="o">=</span> <span class="p">(</span><span class="n">emax</span> <span class="o">-</span> <span class="n">emin</span><span class="p">)</span> <span class="o">/</span> <span class="n">npoints</span>

        <span class="c1"># Use width of at least two grid points</span>
        <span class="k">if</span> <span class="n">width</span> <span class="o">&lt;</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">de</span><span class="p">:</span>
            <span class="n">width</span> <span class="o">=</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">de</span>

        <span class="n">energies</span> <span class="o">=</span> <span class="p">[</span><span class="n">emin</span> <span class="o">+</span> <span class="n">ie</span> <span class="o">*</span> <span class="n">de</span> <span class="k">for</span> <span class="n">ie</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">npoints</span><span class="p">)]</span>

        <span class="n">cutoff</span> <span class="o">=</span> <span class="mf">20.0</span> <span class="o">*</span> <span class="n">width</span>
        <span class="n">gamma</span> <span class="o">=</span> <span class="mf">0.5</span> <span class="o">*</span> <span class="n">width</span>
        <span class="n">gamma_sqrd</span> <span class="o">=</span> <span class="n">gamma</span> <span class="o">*</span> <span class="n">gamma</span>

        <span class="n">de</span> <span class="o">=</span> <span class="p">(</span><span class="n">energies</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">energies</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">/</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">energies</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
        <span class="n">prefac</span> <span class="o">=</span> <span class="n">gamma</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">pi</span> <span class="o">*</span> <span class="n">de</span>

        <span class="n">x</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">y</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">energy</span> <span class="ow">in</span> <span class="n">energies</span><span class="p">:</span>
            <span class="n">xx0</span> <span class="o">=</span> <span class="n">energy</span> <span class="o">-</span> <span class="n">en</span>
            <span class="n">stot</span> <span class="o">=</span> <span class="n">osc</span> <span class="o">/</span> <span class="p">(</span><span class="n">xx0</span> <span class="o">*</span> <span class="n">xx0</span> <span class="o">+</span> <span class="n">gamma_sqrd</span><span class="p">)</span>
            <span class="n">t</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">stot</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">abs</span><span class="p">(</span><span class="n">xx0</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="n">cutoff</span><span class="p">])</span>
            <span class="n">x</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">energy</span><span class="p">)</span>
            <span class="n">y</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">t</span> <span class="o">*</span> <span class="n">prefac</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">ExcitationSpectrum</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="nf">_parse_preamble</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">preamble</span><span class="p">):</span>
        <span class="n">info</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">preamble</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">):</span>
            <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;=&quot;</span><span class="p">)</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">toks</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                <span class="n">info</span><span class="p">[</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()]</span> <span class="o">=</span> <span class="n">toks</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
        <span class="k">return</span> <span class="n">info</span>

    <span class="k">def</span> <span class="fm">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="fm">__iter__</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ind</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="n">ind</span><span class="p">]</span>

    <span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_parse_job</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span>
        <span class="n">energy_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;Total \w+ energy\s+=\s+([.\-\d]+)&#39;</span><span class="p">)</span>
        <span class="n">energy_gas_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;gas phase energy\s+=\s+([.\-\d]+)&#39;</span><span class="p">)</span>
        <span class="n">energy_sol_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;sol phase energy\s+=\s+([.\-\d]+)&#39;</span><span class="p">)</span>
        <span class="n">coord_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;\d+\s+(\w+)\s+[.\-\d]+\s+([.\-\d]+)\s+&#39;</span>
                                <span class="sa">r</span><span class="s1">&#39;([.\-\d]+)\s+([.\-\d]+)&#39;</span><span class="p">)</span>
        <span class="n">lat_vector_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;a[123]=&lt;\s+([.\-\d]+)\s+&#39;</span>
                                     <span class="sa">r</span><span class="s1">&#39;([.\-\d]+)\s+([.\-\d]+)\s+&gt;&#39;</span><span class="p">)</span>
        <span class="n">corrections_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;([\w\-]+ correction to \w+)\s+=&#39;</span>
                                      <span class="sa">r</span><span class="s1">&#39;\s+([.\-\d]+)&#39;</span><span class="p">)</span>
        <span class="n">preamble_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;(No. of atoms|No. of electrons&#39;</span>
                                   <span class="sa">r</span><span class="s1">&#39;|SCF calculation type|Charge|Spin &#39;</span>
                                   <span class="sa">r</span><span class="s1">&#39;multiplicity)\s*:\s*(\S+)&#39;</span><span class="p">)</span>
        <span class="n">force_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;\s+(\d+)\s+(\w+)&#39;</span> <span class="o">+</span> <span class="mi">6</span> <span class="o">*</span> <span class="sa">r</span><span class="s1">&#39;\s+([0-9\.\-]+)&#39;</span><span class="p">)</span>

        <span class="n">time_patt</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span>
            <span class="sa">r</span><span class="s1">&#39;\s+ Task \s+ times \s+ cpu: \s+   ([.\d]+)s .+ &#39;</span><span class="p">,</span> <span class="n">re</span><span class="o">.</span><span class="n">VERBOSE</span><span class="p">)</span>

        <span class="n">error_defs</span> <span class="o">=</span> <span class="p">{</span>
            <span class="s2">&quot;calculations not reaching convergence&quot;</span><span class="p">:</span> <span class="s2">&quot;Bad convergence&quot;</span><span class="p">,</span>
            <span class="s2">&quot;Calculation failed to converge&quot;</span><span class="p">:</span> <span class="s2">&quot;Bad convergence&quot;</span><span class="p">,</span>
            <span class="s2">&quot;geom_binvr: #indep variables incorrect&quot;</span><span class="p">:</span> <span class="s2">&quot;autoz error&quot;</span><span class="p">,</span>
            <span class="s2">&quot;dft optimize failed&quot;</span><span class="p">:</span> <span class="s2">&quot;Geometry optimization failed&quot;</span><span class="p">}</span>

        <span class="k">def</span> <span class="nf">fort2py</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">x</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;D&quot;</span><span class="p">,</span> <span class="s2">&quot;e&quot;</span><span class="p">)</span>

        <span class="k">def</span> <span class="nf">isfloatstring</span><span class="p">(</span><span class="n">s</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">s</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;.&quot;</span><span class="p">)</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span>

        <span class="n">parse_hess</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">parse_proj_hess</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">hessian</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">projected_hessian</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">parse_force</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">all_forces</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">forces</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="n">data</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">energies</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">frequencies</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">normal_frequencies</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="n">corrections</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">molecules</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">structures</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">species</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">coords</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">lattice</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">errors</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">basis_set</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">bset_header</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">parse_geom</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">parse_freq</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">parse_bset</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">parse_projected_freq</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">job_type</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span>
        <span class="n">parse_time</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">time</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">output</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">e</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">error_defs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="k">if</span> <span class="n">l</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">e</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                    <span class="n">errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">v</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">parse_time</span><span class="p">:</span>
                <span class="n">m</span> <span class="o">=</span> <span class="n">time_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                    <span class="n">time</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
                    <span class="n">parse_time</span> <span class="o">=</span> <span class="kc">False</span>
            <span class="k">if</span> <span class="n">parse_geom</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;Atomic Mass&quot;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">lattice</span><span class="p">:</span>
                        <span class="n">structures</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Structure</span><span class="p">(</span><span class="n">lattice</span><span class="p">,</span> <span class="n">species</span><span class="p">,</span> <span class="n">coords</span><span class="p">,</span>
                                                    <span class="n">coords_are_cartesian</span><span class="o">=</span><span class="kc">True</span><span class="p">))</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">molecules</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Molecule</span><span class="p">(</span><span class="n">species</span><span class="p">,</span> <span class="n">coords</span><span class="p">))</span>
                    <span class="n">species</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="n">coords</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="n">lattice</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="n">parse_geom</span> <span class="o">=</span> <span class="kc">False</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">m</span> <span class="o">=</span> <span class="n">coord_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                        <span class="n">species</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">capitalize</span><span class="p">())</span>
                        <span class="n">coords</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">3</span><span class="p">)),</span>
                                       <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">4</span><span class="p">))])</span>
                    <span class="n">m</span> <span class="o">=</span> <span class="n">lat_vector_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                        <span class="n">lattice</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)),</span>
                                        <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">3</span><span class="p">))])</span>

            <span class="k">if</span> <span class="n">parse_force</span><span class="p">:</span>
                <span class="n">m</span> <span class="o">=</span> <span class="n">force_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                    <span class="n">forces</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="nb">float</span><span class="p">,</span> <span class="n">m</span><span class="o">.</span><span class="n">groups</span><span class="p">()[</span><span class="mi">5</span><span class="p">:]))</span>
                <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">forces</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="n">all_forces</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">forces</span><span class="p">)</span>
                    <span class="n">forces</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="n">parse_force</span> <span class="o">=</span> <span class="kc">False</span>

            <span class="k">elif</span> <span class="n">parse_freq</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">normal_frequencies</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                        <span class="k">continue</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">parse_freq</span> <span class="o">=</span> <span class="kc">False</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">vibs</span> <span class="o">=</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">vib</span><span class="p">)</span> <span class="k">for</span> <span class="n">vib</span> <span class="ow">in</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">1</span><span class="p">:]]</span>
                    <span class="n">num_vibs</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">vibs</span><span class="p">)</span>
                    <span class="k">for</span> <span class="n">mode</span><span class="p">,</span> <span class="n">dis</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">normal_frequencies</span><span class="p">[</span><span class="o">-</span><span class="n">num_vibs</span><span class="p">:],</span> <span class="n">vibs</span><span class="p">):</span>
                        <span class="n">mode</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dis</span><span class="p">)</span>

            <span class="k">elif</span> <span class="n">parse_projected_freq</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">frequencies</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">])</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                        <span class="k">continue</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">parse_projected_freq</span> <span class="o">=</span> <span class="kc">False</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">vibs</span> <span class="o">=</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">vib</span><span class="p">)</span> <span class="k">for</span> <span class="n">vib</span> <span class="ow">in</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">1</span><span class="p">:]]</span>
                    <span class="n">num_vibs</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">vibs</span><span class="p">)</span>
                    <span class="k">for</span> <span class="n">mode</span><span class="p">,</span> <span class="n">dis</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span>
                            <span class="n">frequencies</span><span class="p">[</span><span class="o">-</span><span class="n">num_vibs</span><span class="p">:],</span> <span class="n">vibs</span><span class="p">):</span>
                        <span class="n">mode</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dis</span><span class="p">)</span>

            <span class="k">elif</span> <span class="n">parse_bset</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                    <span class="n">parse_bset</span> <span class="o">=</span> <span class="kc">False</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                    <span class="k">if</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">&quot;Tag&quot;</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;-+&quot;</span><span class="p">,</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
                        <span class="n">basis_set</span><span class="p">[</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span><span class="n">bset_header</span><span class="p">[</span><span class="mi">1</span><span class="p">:],</span>
                                                      <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">:]))</span>
                    <span class="k">elif</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;Tag&quot;</span><span class="p">:</span>
                        <span class="n">bset_header</span> <span class="o">=</span> <span class="n">toks</span>
                        <span class="n">bset_header</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span>
                        <span class="n">bset_header</span> <span class="o">=</span> <span class="p">[</span><span class="n">h</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">bset_header</span><span class="p">]</span>

            <span class="k">elif</span> <span class="n">parse_hess</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                    <span class="k">continue</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">hessian</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="ow">and</span> <span class="n">l</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;----------&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                    <span class="n">parse_hess</span> <span class="o">=</span> <span class="kc">False</span>
                    <span class="k">continue</span>
                <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">toks</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="k">try</span><span class="p">:</span>
                        <span class="n">row</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                    <span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
                        <span class="k">continue</span>
                    <span class="k">if</span> <span class="n">isfloatstring</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">]):</span>
                        <span class="k">continue</span>
                    <span class="n">vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">fort2py</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">:]]</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">hessian</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">row</span><span class="p">:</span>
                        <span class="n">hessian</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">vals</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">hessian</span><span class="p">[</span><span class="n">row</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">vals</span><span class="p">)</span>

            <span class="k">elif</span> <span class="n">parse_proj_hess</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                    <span class="k">continue</span>
                <span class="n">nat3</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">hessian</span><span class="p">)</span>
                <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">toks</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="k">try</span><span class="p">:</span>
                        <span class="n">row</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                    <span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
                        <span class="k">continue</span>
                    <span class="k">if</span> <span class="n">isfloatstring</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">]):</span>
                        <span class="k">continue</span>
                    <span class="n">vals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">float</span><span class="p">(</span><span class="n">fort2py</span><span class="p">(</span><span class="n">x</span><span class="p">))</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">:]]</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">projected_hessian</span><span class="p">)</span> <span class="o">&lt;</span> <span class="n">row</span><span class="p">:</span>
                        <span class="n">projected_hessian</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">vals</span><span class="p">)</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">projected_hessian</span><span class="p">[</span><span class="n">row</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">vals</span><span class="p">)</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">projected_hessian</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span> <span class="o">==</span> <span class="n">nat3</span><span class="p">:</span>
                        <span class="n">parse_proj_hess</span> <span class="o">=</span> <span class="kc">False</span>

            <span class="k">else</span><span class="p">:</span>
                <span class="n">m</span> <span class="o">=</span> <span class="n">energy_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                    <span class="n">energies</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Energy</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="s2">&quot;Ha&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="s2">&quot;eV&quot;</span><span class="p">))</span>
                    <span class="n">parse_time</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">continue</span>

                <span class="n">m</span> <span class="o">=</span> <span class="n">energy_gas_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                    <span class="n">cosmo_scf_energy</span> <span class="o">=</span> <span class="n">energies</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
                    <span class="n">energies</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
                    <span class="n">energies</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;cosmo scf&quot;</span><span class="p">:</span> <span class="n">cosmo_scf_energy</span><span class="p">})</span>
                    <span class="n">energies</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;gas phase&quot;</span><span class="p">:</span> <span class="n">Energy</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="s2">&quot;Ha&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="s2">&quot;eV&quot;</span><span class="p">)})</span>

                <span class="n">m</span> <span class="o">=</span> <span class="n">energy_sol_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                    <span class="n">energies</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;sol phase&quot;</span><span class="p">:</span> <span class="n">Energy</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="s2">&quot;Ha&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="s2">&quot;eV&quot;</span><span class="p">)})</span>

                <span class="n">m</span> <span class="o">=</span> <span class="n">preamble_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                    <span class="k">try</span><span class="p">:</span>
                        <span class="n">val</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
                    <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
                        <span class="n">val</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
                    <span class="n">k</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;No. of &quot;</span><span class="p">,</span> <span class="s2">&quot;n&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="s2">&quot;_&quot;</span><span class="p">)</span>
                    <span class="n">data</span><span class="p">[</span><span class="n">k</span><span class="o">.</span><span class="n">lower</span><span class="p">()]</span> <span class="o">=</span> <span class="n">val</span>
                <span class="k">elif</span> <span class="n">l</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;Geometry </span><span class="se">\&quot;</span><span class="s2">geometry</span><span class="se">\&quot;</span><span class="s2">&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                    <span class="n">parse_geom</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="k">elif</span> <span class="n">l</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;Summary of </span><span class="se">\&quot;</span><span class="s2">ao basis</span><span class="se">\&quot;</span><span class="s2">&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                    <span class="n">parse_bset</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="k">elif</span> <span class="n">l</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;P.Frequency&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                    <span class="n">parse_projected_freq</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">if</span> <span class="n">frequencies</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                        <span class="n">frequencies</span> <span class="o">=</span> <span class="p">[]</span>
                    <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">1</span><span class="p">:]</span>
                    <span class="n">frequencies</span><span class="o">.</span><span class="n">extend</span><span class="p">([(</span><span class="nb">float</span><span class="p">(</span><span class="n">freq</span><span class="p">),</span> <span class="p">[])</span> <span class="k">for</span> <span class="n">freq</span> <span class="ow">in</span> <span class="n">toks</span><span class="p">])</span>

                <span class="k">elif</span> <span class="n">l</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;Frequency&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                    <span class="n">toks</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">toks</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;Frequency&quot;</span><span class="p">:</span>
                        <span class="n">parse_freq</span> <span class="o">=</span> <span class="kc">True</span>
                        <span class="k">if</span> <span class="n">normal_frequencies</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                            <span class="n">normal_frequencies</span> <span class="o">=</span> <span class="p">[]</span>
                        <span class="n">normal_frequencies</span><span class="o">.</span><span class="n">extend</span><span class="p">([(</span><span class="nb">float</span><span class="p">(</span><span class="n">freq</span><span class="p">),</span> <span class="p">[])</span> <span class="k">for</span> <span class="n">freq</span>
                                                   <span class="ow">in</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">1</span><span class="p">:]])</span>

                <span class="k">elif</span> <span class="n">l</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;MASS-WEIGHTED NUCLEAR HESSIAN&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                    <span class="n">parse_hess</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">if</span> <span class="ow">not</span> <span class="n">hessian</span><span class="p">:</span>
                        <span class="n">hessian</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">elif</span> <span class="n">l</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;MASS-WEIGHTED PROJECTED HESSIAN&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                    <span class="n">parse_proj_hess</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">if</span> <span class="ow">not</span> <span class="n">projected_hessian</span><span class="p">:</span>
                        <span class="n">projected_hessian</span> <span class="o">=</span> <span class="p">[]</span>

                <span class="k">elif</span> <span class="n">l</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s2">&quot;atom               coordinates                        gradient&quot;</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
                    <span class="n">parse_force</span> <span class="o">=</span> <span class="kc">True</span>

                <span class="k">elif</span> <span class="n">job_type</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span> <span class="ow">and</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;NWChem&quot;</span><span class="p">):</span>
                    <span class="n">job_type</span> <span class="o">=</span> <span class="n">l</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
                    <span class="k">if</span> <span class="n">job_type</span> <span class="o">==</span> <span class="s2">&quot;NWChem DFT Module&quot;</span> <span class="ow">and</span> \
                            <span class="s2">&quot;COSMO solvation results&quot;</span> <span class="ow">in</span> <span class="n">output</span><span class="p">:</span>
                        <span class="n">job_type</span> <span class="o">+=</span> <span class="s2">&quot; COSMO&quot;</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">m</span> <span class="o">=</span> <span class="n">corrections_patt</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">l</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                        <span class="n">corrections</span><span class="p">[</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)]</span> <span class="o">=</span> <span class="n">FloatWithUnit</span><span class="p">(</span>
                            <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="s2">&quot;kJ mol^-1&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">to</span><span class="p">(</span><span class="s2">&quot;eV atom^-1&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">frequencies</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">freq</span><span class="p">,</span> <span class="n">mode</span> <span class="ow">in</span> <span class="n">frequencies</span><span class="p">:</span>
                <span class="n">mode</span><span class="p">[:]</span> <span class="o">=</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="nb">iter</span><span class="p">(</span><span class="n">mode</span><span class="p">)]</span> <span class="o">*</span> <span class="mi">3</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">normal_frequencies</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">freq</span><span class="p">,</span> <span class="n">mode</span> <span class="ow">in</span> <span class="n">normal_frequencies</span><span class="p">:</span>
                <span class="n">mode</span><span class="p">[:]</span> <span class="o">=</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="p">[</span><span class="nb">iter</span><span class="p">(</span><span class="n">mode</span><span class="p">)]</span> <span class="o">*</span> <span class="mi">3</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">hessian</span><span class="p">:</span>
            <span class="n">n</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">hessian</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span>
                    <span class="n">hessian</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hessian</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="n">i</span><span class="p">])</span>
        <span class="k">if</span> <span class="n">projected_hessian</span><span class="p">:</span>
            <span class="n">n</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">projected_hessian</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span>
                    <span class="n">projected_hessian</span><span class="p">[</span><span class="n">i</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">projected_hessian</span><span class="p">[</span><span class="n">j</span><span class="p">][</span><span class="n">i</span><span class="p">])</span>

        <span class="n">data</span><span class="o">.</span><span class="n">update</span><span class="p">({</span><span class="s2">&quot;job_type&quot;</span><span class="p">:</span> <span class="n">job_type</span><span class="p">,</span> <span class="s2">&quot;energies&quot;</span><span class="p">:</span> <span class="n">energies</span><span class="p">,</span>
                     <span class="s2">&quot;corrections&quot;</span><span class="p">:</span> <span class="n">corrections</span><span class="p">,</span>
                     <span class="s2">&quot;molecules&quot;</span><span class="p">:</span> <span class="n">molecules</span><span class="p">,</span>
                     <span class="s2">&quot;structures&quot;</span><span class="p">:</span> <span class="n">structures</span><span class="p">,</span>
                     <span class="s2">&quot;basis_set&quot;</span><span class="p">:</span> <span class="n">basis_set</span><span class="p">,</span>
                     <span class="s2">&quot;errors&quot;</span><span class="p">:</span> <span class="n">errors</span><span class="p">,</span>
                     <span class="s2">&quot;has_error&quot;</span><span class="p">:</span> <span class="nb">len</span><span class="p">(</span><span class="n">errors</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">,</span>
                     <span class="s2">&quot;frequencies&quot;</span><span class="p">:</span> <span class="n">frequencies</span><span class="p">,</span>
                     <span class="s2">&quot;normal_frequencies&quot;</span><span class="p">:</span> <span class="n">normal_frequencies</span><span class="p">,</span>
                     <span class="s2">&quot;hessian&quot;</span><span class="p">:</span> <span class="n">hessian</span><span class="p">,</span>
                     <span class="s2">&quot;projected_hessian&quot;</span><span class="p">:</span> <span class="n">projected_hessian</span><span class="p">,</span>
                     <span class="s2">&quot;forces&quot;</span><span class="p">:</span> <span class="n">all_forces</span><span class="p">,</span>
                     <span class="s2">&quot;task_time&quot;</span><span class="p">:</span> <span class="n">time</span><span class="p">})</span>

        <span class="k">return</span> <span class="n">data</span></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.nwchem</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>